Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HardwarePWM Esp32 - added assert for max pwm channels #2904

Merged
merged 13 commits into from
Nov 4, 2024

Conversation

pljakobs
Copy link
Contributor

if called with more than the supported channels (depending on the SoC), the constructor would silently fail, yielding a misleading error message.

Copy link

what-the-diff bot commented Oct 30, 2024

PR Summary

  • Additional Constraint for no_of_pins
    An extra validation has been added to ensure that the parameter no_of_pins does not exceed the maximum allowable value, defined as SOC_LEDC_CHANNEL_NUM for better data integrity and system stability.

  • Reorganized Order of Checks and Code Clarity
    The sequence of examination to check if no_of_pins equals 0 has been moved prior to the step to enable the peripheral module resulting in more efficient troubleshooting and execution. The related code has also been restructured for better understandability, leading to easier maintenance.

  • Uninterrupted Enabling Process
    Despite the assertion and condition checks' adjustments, the process to enable the peripheral module stays the same and is still triggered after these checks are completed, ensuring smooth operation.

Copy link
Contributor

@mikee47 mikee47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition for PWM_CHANNEL_NUM_MAX in Sming/Arch/Esp32/Components/driver/include/pwm.h should always be obtained from the IDF. We cannot make assumptions, please amend to:

include <soc/soc_caps.h>

#define PWM_CHANNEL_NUM_MAX SOC_LEDC_CHANNEL_NUM

Sming/Arch/Esp32/Core/HardwarePWM.cpp Outdated Show resolved Hide resolved
@mikee47
Copy link
Contributor

mikee47 commented Oct 31, 2024

@pljakobs It would be nice to have the Basic_HwPWM sample working for esp32. Would you like to include that in this PR?

@pljakobs
Copy link
Contributor Author

@pljakobs It would be nice to have the Basic_HwPWM sample working for esp32. Would you like to include that in this PR?

I have been using just that with minor changes. Will create a new PR

Copy link
Contributor

@mikee47 mikee47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken the liberty of fixing pwm.h. All good, thank you for the fix!

@slaff slaff added this to the 6.0.0 milestone Oct 31, 2024
slaff pushed a commit that referenced this pull request Oct 31, 2024
This PR updates the Sming coding style documentation as discussed in #2898 (comment) and #2904 (comment).

Sming requires version 8 which is generally no longer available in the standard repositories for recent GNU/Linux distributions. Different versions of clang-format produce different output with the same configuration. This is such a common problem that a kind soul has provided standalone builds here https://github.com/muttleyxd/clang-tools-static-binaries/releases.

The default name of the clang-format executable has been changed to `clang-format-8`. This is because `clang-format` is now very unlikely to be the default installed version, and so avoids the subtle issues with running the wrong version.
@pljakobs
Copy link
Contributor Author

pljakobs commented Nov 1, 2024

I've taken the liberty of fixing pwm.h. All good, thank you for the fix!

oh heck, was I still missing somehing? I thought I had it fixed. Thank you.

@slaff slaff merged commit 9054e94 into SmingHub:develop Nov 4, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants